<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
	<title>个人注册</title>
	<link rel="icon" href="./img/favicon.ico">


    <link rel="stylesheet" type="text/css" href="./css/all.css" />
    <link rel="stylesheet" type="text/css" href="./css/pages-register.css" />
</head>

<body>
<div id="app">
	<div class="register py-container ">
		<!--register-->
		<div class="registerArea">
			<h3>注册新用户<span class="go">我有账号，去<a href="loginByAccount.html" target="_blank">登陆</a></span></h3>
			<div class="info">
				<form class="sui-form form-horizontal">
					<div class="control-group">
						<label for="inputPassword" class="control-label">账号：</label>
						<div class="controls">
							<input type="text" placeholder="设置登录账号" class="input-xfat input-xlarge" v-model="account">
							<label>{{accountMessage}}</label>
						</div>
					</div>
					<div class="control-group">
						<label for="inputPassword" class="control-label">登录密码：</label>
						<div class="controls">
							<input type="password" placeholder="设置登录密码" class="input-xfat input-xlarge" v-model="password">
						</div>
					</div>
					<div class="control-group">
						<label for="inputPassword" class="control-label">确认密码：</label>
						<div class="controls">
							<input type="password" placeholder="再次确认密码" class="input-xfat input-xlarge" v-model="repassword">
							<label>{{passwordMessage}}</label>
						</div>
					</div>
					<!-- 手机号 -->
					<div class="control-group">
						<label class="control-label">手机号：</label>
						<div class="controls">
							<input type="text" placeholder="请输入你的手机号" class="input-xfat input-xlarge" v-model="phoneNum">
							<label>{{phoneMessage}}</label>
							<a @click="send()">发送短信验证码</a>
						</div>
					</div>
					<div class="control-group">
						<label for="inputPassword" class="control-label">验证码：</label>
						<div class="controls">
							<input type="text" placeholder="验证码" class="input-xfat input-xlarge" v-model="code">
							<label>{{errorMessage}}</label>
						</div>
					</div>
					<div class="control-group">
						<label for="inputPassword" class="control-label">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
						<div class="controls">
							<input name="m1" type="checkbox" value="2" checked=""><span>同意协议并注册《用户协议》</span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label"></label>
						<div class="controls btn-reg">
							<a class="sui-btn btn-block btn-xlarge btn-danger" @click="register()">完成注册</a>
						</div>
					</div>
				</form>
				<div class="clearfix"></div>
			</div>
		</div>
	</div>



</div>
</body>

<script src="js/vue.js"></script>
<script src="js/axios.js"></script>

<script>
	new Vue({
		el:"#app",
		data:{
			phoneNum:"",
			code:"",
			password:"",
			account:"",
			errorMessage:"",
			repassword:"",
			phoneMessage:"",
			accountMessage:"",
			passwordMessage:"",
		},
		methods:{
			send:function(){
				//通过对象传参
				var params = new URLSearchParams();
				params.append("phoneNum",this.phoneNum);
				axios.post(
					"/text/send",
					params
				);
			},
			register:function(){
				//通过对象传参
				var params = new URLSearchParams();
				params.append("phoneNum",this.phoneNum);
				params.append("account",this.account);
				params.append("password",this.password);
				params.append("repassword",this.repassword);
				params.append("code",this.code);
				axios.post(
					"/user/register",
					params
				).then(res =>{
					if(res.data.code==1){
						this.passwordMessage=res.data.msg;
					}
					if(res.data.code==2){
						this.errorMessage=res.data.msg;
					}
					if(res.data.code==11){
						this.accountMessage=res.data.msg;
					}
					if(res.data.code==22){
						this.phoneMessage=res.data.msg;
					}
				
					if(res.data.code==200){
						alert("注册成功");
						window.location.href="/woniuuser/loginByAccount.html";
					}
				});
			}
		}
	});


</script>


</html>